package com.woniuxy.sd.action;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;


@SuppressWarnings("serial")
public class DownLoadAction extends ActionSupport{
	
		//读取下载文件的目录
		private String inputPath;
		//下载文件的文件名
		private String fileName;
		//下载文件的类型
		private String conetntType;
		
		public String getInputPath() {
			return inputPath;
		}

		public void setInputPath(String inputPath) {
			this.inputPath = inputPath;
		}

		public String getFileName() {
			return fileName;
		}

		public void setFileName(String fileName) {
			this.fileName = fileName;
		}

		public String getConetntType() {
			return conetntType;
		}

		public void setConetntType(String conetntType) {
			this.conetntType = conetntType;
		}


		public  InputStream getInputStream() throws FileNotFoundException{
			String path=ServletActionContext.getServletContext().getRealPath(inputPath);
			 try {
				path = new String(path.getBytes(),"utf-8");
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println(path);
			return new BufferedInputStream(new FileInputStream(path+"\\"+fileName));														
		}

}

